package io.github.echarts.option.series;

import io.github.echarts.option.style.ItemStyle;
import io.github.echarts.option.style.LabelStyle;
import io.github.echarts.option.style.LineStyle;
import java.util.List;

/**
 * 仪表盘图表配置类
 */
public class GaugeSeries extends SeriesOption {

    /**
     * 最小值
     */
    private Double min;

    /**
     * 最大值
     */
    private Double max;

    /**
     * 起始角度，单位度数
     * 默认为225度，0度为水平向右
     */
    private Double startAngle;

    /**
     * 结束角度，单位度数
     * 默认为-45度，也就是负数表示逆时针
     */
    private Double endAngle;

    /**
     * 仪表盘半径，可以是绝对值或百分比
     */
    private String radius;

    /**
     * 仪表盘轴线相关配置
     */
    private AxisLine axisLine;

    /**
     * 仪表盘刻度相关配置
     */
    private AxisTick axisTick;

    /**
     * 仪表盘刻度标签相关配置
     */
    private AxisLabel axisLabel;

    /**
     * 仪表盘指针相关配置
     */
    private Pointer pointer;

    /**
     * 锚点相关配置
     */
    private Anchor anchor;

    /**
     * 进度条相关配置
     */
    private Progress progress;

    /**
     * 仪表盘的详情
     */
    private Detail detail;

    /**
     * 构造函数，自动设置类型为仪表盘
     */
    public GaugeSeries() {
        super();
        setType("gauge");
    }

    /**
     * 仪表盘轴线配置项
     */
    public static class AxisLine {
        /**
         * 是否显示仪表盘轴线
         */
        private Boolean show;

        /**
         * 轴线样式
         */
        private LineStyle lineStyle;

        /**
         * 轴线配置数组，可以设置不同颜色的轴段
         * 例如：[[0.3, '#67e0e3'], [0.7, '#37a2da'], [1, '#fd666d']]
         * 表示0-30%为#67e0e3, 30%-70%为#37a2da, 70%-100%为#fd666d
         */
        private List<Object[]> segments;

        public Boolean getShow() {
            return show;
        }

        public void setShow(Boolean show) {
            this.show = show;
        }

        public LineStyle getLineStyle() {
            return lineStyle;
        }

        public void setLineStyle(LineStyle lineStyle) {
            this.lineStyle = lineStyle;
        }

        public List<Object[]> getSegments() {
            return segments;
        }

        public void setSegments(List<Object[]> segments) {
            this.segments = segments;
        }
    }

    /**
     * 刻度配置项
     */
    public static class AxisTick {
        /**
         * 是否显示刻度
         */
        private Boolean show;

        /**
         * 分割段数，默认为10
         */
        private Integer splitNumber;

        /**
         * 刻度线长度
         */
        private Double length;

        /**
         * 刻度线样式
         */
        private LineStyle lineStyle;

        public Boolean getShow() {
            return show;
        }

        public void setShow(Boolean show) {
            this.show = show;
        }

        public Integer getSplitNumber() {
            return splitNumber;
        }

        public void setSplitNumber(Integer splitNumber) {
            this.splitNumber = splitNumber;
        }

        public Double getLength() {
            return length;
        }

        public void setLength(Double length) {
            this.length = length;
        }

        public LineStyle getLineStyle() {
            return lineStyle;
        }

        public void setLineStyle(LineStyle lineStyle) {
            this.lineStyle = lineStyle;
        }
    }

    /**
     * 刻度标签配置项
     */
    public static class AxisLabel {
        /**
         * 是否显示刻度标签
         */
        private Boolean show;

        /**
         * 标签距离刻度线的距离
         */
        private Double distance;

        /**
         * 标签格式化函数，支持字符串模板和回调函数
         * 在Java环境中通常使用字符串模板，例如：{value}
         */
        private String formatter;

        /**
         * 文本样式
         */
        private LabelStyle textStyle;

        public Boolean getShow() {
            return show;
        }

        public void setShow(Boolean show) {
            this.show = show;
        }

        public Double getDistance() {
            return distance;
        }

        public void setDistance(Double distance) {
            this.distance = distance;
        }

        public String getFormatter() {
            return formatter;
        }

        public void setFormatter(String formatter) {
            this.formatter = formatter;
        }

        public LabelStyle getTextStyle() {
            return textStyle;
        }

        public void setTextStyle(LabelStyle textStyle) {
            this.textStyle = textStyle;
        }
    }

    /**
     * 指针配置项
     */
    public static class Pointer {
        /**
         * 是否显示指针
         */
        private Boolean show;

        /**
         * 指针长度，可以是绝对值或相对于半径的百分比
         */
        private String length;

        /**
         * 指针宽度
         */
        private Double width;

        /**
         * 指针样式
         */
        private ItemStyle itemStyle;

        public Boolean getShow() {
            return show;
        }

        public void setShow(Boolean show) {
            this.show = show;
        }

        public String getLength() {
            return length;
        }

        public void setLength(String length) {
            this.length = length;
        }

        public Double getWidth() {
            return width;
        }

        public void setWidth(Double width) {
            this.width = width;
        }

        public ItemStyle getItemStyle() {
            return itemStyle;
        }

        public void setItemStyle(ItemStyle itemStyle) {
            this.itemStyle = itemStyle;
        }
    }

    /**
     * 锚点配置项
     */
    public static class Anchor {
        /**
         * 是否显示锚点
         */
        private Boolean show;

        /**
         * 锚点大小
         */
        private Double size;

        /**
         * 是否显示锚点的图标
         */
        private Boolean showAbove;

        /**
         * 锚点样式
         */
        private ItemStyle itemStyle;

        public Boolean getShow() {
            return show;
        }

        public void setShow(Boolean show) {
            this.show = show;
        }

        public Double getSize() {
            return size;
        }

        public void setSize(Double size) {
            this.size = size;
        }

        public Boolean getShowAbove() {
            return showAbove;
        }

        public void setShowAbove(Boolean showAbove) {
            this.showAbove = showAbove;
        }

        public ItemStyle getItemStyle() {
            return itemStyle;
        }

        public void setItemStyle(ItemStyle itemStyle) {
            this.itemStyle = itemStyle;
        }
    }

    /**
     * 进度条配置项
     */
    public static class Progress {
        /**
         * 是否显示进度条
         */
        private Boolean show;

        /**
         * 进度条宽度
         */
        private Double width;

        /**
         * 进度条样式
         */
        private ItemStyle itemStyle;

        /**
         * 是否裁剪超出部分
         */
        private Boolean clip;

        public Boolean getShow() {
            return show;
        }

        public void setShow(Boolean show) {
            this.show = show;
        }

        public Double getWidth() {
            return width;
        }

        public void setWidth(Double width) {
            this.width = width;
        }

        public ItemStyle getItemStyle() {
            return itemStyle;
        }

        public void setItemStyle(ItemStyle itemStyle) {
            this.itemStyle = itemStyle;
        }

        public Boolean getClip() {
            return clip;
        }

        public void setClip(Boolean clip) {
            this.clip = clip;
        }
    }

    /**
     * 仪表盘详情配置项
     */
    public static class Detail {
        /**
         * 是否显示详情
         */
        private Boolean show;

        /**
         * 文本格式化器
         */
        private String formatter;

        /**
         * 相对于仪表盘中心的偏移位置，数组第一项是水平方向的偏移，第二项是垂直方向的偏移
         */
        private Double[] offsetCenter;

        /**
         * 文本样式
         */
        private LabelStyle textStyle;

        /**
         * 详情值的背景颜色
         */
        private String backgroundColor;

        /**
         * 详情值的边框宽度
         */
        private Double borderWidth;

        /**
         * 详情值的边框颜色
         */
        private String borderColor;

        /**
         * 详情值的圆角半径
         */
        private Double borderRadius;

        /**
         * 详情值的内边距
         */
        private Double[] padding;

        public Boolean getShow() {
            return show;
        }

        public void setShow(Boolean show) {
            this.show = show;
        }

        public String getFormatter() {
            return formatter;
        }

        public void setFormatter(String formatter) {
            this.formatter = formatter;
        }

        public Double[] getOffsetCenter() {
            return offsetCenter;
        }

        public void setOffsetCenter(Double[] offsetCenter) {
            this.offsetCenter = offsetCenter;
        }

        public LabelStyle getTextStyle() {
            return textStyle;
        }

        public void setTextStyle(LabelStyle textStyle) {
            this.textStyle = textStyle;
        }

        public String getBackgroundColor() {
            return backgroundColor;
        }

        public void setBackgroundColor(String backgroundColor) {
            this.backgroundColor = backgroundColor;
        }

        public Double getBorderWidth() {
            return borderWidth;
        }

        public void setBorderWidth(Double borderWidth) {
            this.borderWidth = borderWidth;
        }

        public String getBorderColor() {
            return borderColor;
        }

        public void setBorderColor(String borderColor) {
            this.borderColor = borderColor;
        }

        public Double getBorderRadius() {
            return borderRadius;
        }

        public void setBorderRadius(Double borderRadius) {
            this.borderRadius = borderRadius;
        }

        public Double[] getPadding() {
            return padding;
        }

        public void setPadding(Double[] padding) {
            this.padding = padding;
        }
    }

    // Getters and Setters
    public Double getMin() {
        return min;
    }

    public void setMin(Double min) {
        this.min = min;
    }

    public Double getMax() {
        return max;
    }

    public void setMax(Double max) {
        this.max = max;
    }

    public Double getStartAngle() {
        return startAngle;
    }

    public void setStartAngle(Double startAngle) {
        this.startAngle = startAngle;
    }

    public Double getEndAngle() {
        return endAngle;
    }

    public void setEndAngle(Double endAngle) {
        this.endAngle = endAngle;
    }

    public String getRadius() {
        return radius;
    }

    public void setRadius(String radius) {
        this.radius = radius;
    }

    public AxisLine getAxisLine() {
        return axisLine;
    }

    public void setAxisLine(AxisLine axisLine) {
        this.axisLine = axisLine;
    }

    public AxisTick getAxisTick() {
        return axisTick;
    }

    public void setAxisTick(AxisTick axisTick) {
        this.axisTick = axisTick;
    }

    public AxisLabel getAxisLabel() {
        return axisLabel;
    }

    public void setAxisLabel(AxisLabel axisLabel) {
        this.axisLabel = axisLabel;
    }

    public Pointer getPointer() {
        return pointer;
    }

    public void setPointer(Pointer pointer) {
        this.pointer = pointer;
    }

    public Anchor getAnchor() {
        return anchor;
    }

    public void setAnchor(Anchor anchor) {
        this.anchor = anchor;
    }

    public Progress getProgress() {
        return progress;
    }

    public void setProgress(Progress progress) {
        this.progress = progress;
    }

    public Detail getDetail() {
        return detail;
    }

    public void setDetail(Detail detail) {
        this.detail = detail;
    }

    /**
     * 设置仪表盘数据
     * 
     * @param value 仪表盘数值
     */
    public void setData(Number value) {
        // 创建数据对象数组
        Object[] dataItem = new Object[1];
        dataItem[0] = value;
        
        // 设置数据
        Object[][] data = new Object[1][];
        data[0] = dataItem;
        setData(data);
    }
    
    /**
     * 设置仪表盘数据
     * 
     * @param value 仪表盘数值
     * @param name 仪表盘名称
     */
    public void setData(Number value, String name) {
        // 创建数据对象数组
        Object[] dataItem = new Object[2];
        dataItem[0] = value;
        dataItem[1] = name;
        
        // 设置数据
        Object[][] data = new Object[1][];
        data[0] = dataItem;
        setData(data);
    }
} 